import books.BookList;
import user.AdminUser;
import user.OrdUser;
import user.User;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        BookList bookList = new BookList() ;

       try{
           User user = selectUser() ;
           while(true) {
               int choose = user.menu() ;
               user.iOperations[choose].work(bookList);
           }
       }catch (InputMismatchException e){
           System.out.println("输入错误，已退出系统");
       }


    }
  public static User selectUser(){
      Scanner scan = new Scanner(System.in) ;
      System.out.println("欢迎来到图书系统");
      System.out.println("请输入你的名字:");
      String name = scan.nextLine() ;
        int tmp = 0 ;
      while(true){
          System.out.println("请输入你的身份:  1. 管理员   2 . 学生");
           tmp = scan.nextInt();
          if(tmp == 1 || tmp == 2){
            break ;
          }else{
              System.out.println("输入错误，请重新输入;");
          }
      }
      if(tmp ==1){
          System.out.println("你好！ "+name + "管理员  欢迎来到图书系统");
          return new AdminUser();
      }else{
          System.out.println("你好！ "+name + "同学  欢迎来到图书系统");
          return new OrdUser();
      }
  }

}
